import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:life_service/color/hex.dart';
import 'package:life_service/components/order/all.dart';
import 'package:life_service/extensions/ex_widget.dart';
import 'package:life_service/ui/keep_alive.dart';
import 'package:life_service/utils/styles.dart';
import 'package:life_service/utils/tools.dart';
import '../controller.dart';

class MineOrderListPage extends GetView<MineOrderListController> {
  const MineOrderListPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: HexColor(HexColor.colorF2f2),
      appBar: PreferredSize(
        preferredSize: Size.fromHeight(Get.mediaQuery.padding.top + 80),
        child: AnnotatedRegion<SystemUiOverlayStyle>(
          value: SystemUiOverlayStyle.dark,
          child: ColoredBox(
            color: Colors.white,
            child: Column(
              children: [
                Container(
                  padding: Get.mediaQuery.padding,
                  alignment: Alignment.centerLeft,
                  child: TextButton(
                    onPressed: Get.back,
                    child: Text.rich(
                      TextSpan(
                        children: [
                          const WidgetSpan(
                            child: Icon(
                              CupertinoIcons.chevron_back,
                              size: 18,
                              color: Colors.black,
                            ),
                          ),
                          TextSpan(
                            text: ' 订单',
                            style: StylesUtils.customTextStyle(
                              fontSize: StylesUtils.fontSize16,
                              color: HexColor.color3333,
                            ),
                          ),
                        ],
                      ),
                    ),
                  ),
                ).expand(),
                Container(
                  height: 36,
                  alignment: Alignment.topLeft,
                  padding: const EdgeInsets.only(bottom: 2),
                  decoration: BoxDecoration(
                    border: Border(
                      bottom: BorderSide(
                        color: HexColor(HexColor.colorF2f2),
                      ),
                    ),
                  ),
                  child: ToolsUtils.getClientTabBar(
                    controller.tabs,
                    controller.controller,
                    indicatorMinWidth: 20,
                    indicatorWeight: 3,
                    isScrollable: false,
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
      body: TabBarView(
        controller: controller.controller,
        children: [
          KeepAliveWrapperView(
            child: const OrderAllView(),
            callback: () {
              Get.lazyPut(() => OrderAllController());
            },
          ),
          KeepAliveWrapperView(
            child: const OrderPendingPaymentView(),
            callback: () {
              Get.lazyPut(() => OrderPendingPaymentController());
            },
          ),
          KeepAliveWrapperView(
            child: const OrderCheckInView(),
            callback: () {
              Get.lazyPut(() => OrderCheckInController());
            },
          ),
          KeepAliveWrapperView(
            child: const OrderConsumedView(),
            callback: () {
              Get.lazyPut(() => OrderConsumedController());
            },
          ),
        ],
      ),
    );
  }
}
